/**
 * 
 */
package com.ffcs.crmd.tsp.server.application;

import java.util.HashMap;
import java.util.Map;

/**
 * 功能说明:
 *
 * @author FFCS-ZHONGFUHUA
 * 
 * @since 
 *
 */
public class ApplicationManagerHolder {
    
    private final Map<String, Object>       singletonObjects   = new HashMap<String, Object>();
    
    private static ApplicationManagerHolder applicationManager = new ApplicationManagerHolder();
    
    @SuppressWarnings("unchecked")
    public static <T> T getBean(String name, Class<T> requiredType) {
        if (applicationManager.getSingletonObjects().containsKey(name)) {
            Object object = applicationManager.getSingletonObjects().get(name);
            if (requiredType != null && !requiredType.isInstance(object)) {
                return null;
            }
            return (T) object;
        }
        return null;
    }
    
    public static void register(String name, Object objectDest) {
        applicationManager.getSingletonObjects().put(name, objectDest);
    }
    
    public Map<String, Object> getSingletonObjects() {
        return singletonObjects;
    }
    
}
